home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Tech Arsenal 1
/
Tech Arsenal (Arsenal Computer).ISO
/
tek-11
/
prohp5.zip
/
DPRINV.PRG
< prev
next >
Wrap
Text File
|
1993-02-10
|
10KB
|
279 lines
/*
┌─────────────────────────────────────────────────────────────────────────┐
│ │
│ Program : Prinv.prg │
│ Usage : │
│ Purpose : Here's how to create an Invoice Form with shadow boxes. │
│ Store it to a string type var, make it a macro and │
│ then call it each time you need the form. │
│ You may also save the invoice to a file │
│ and download it later. │
│ │
│ Author : Copyright (C) 1992, I.L.A.,Inc. All Rights reserved. │
│ │
│ Comments: This source code may be distributed and used freely │
│ provided that the copyright notice is not removed. │
│ │
└─────────────────────────────────────────────────────────────────────────┘
*/
#include "prohp.ch"
proc main()
Local HPCinv:=""
set2print("dprinv.hpc")
HP_init()
HP_send(.T.)
// process the invoice internally
HP_orient(PORTRAIT)
HPscale(100)
PrInvoice(0.5,0.5,7,5)
HP_reset()
HPscale(65)
PrInvoice(0.5,0.5,7,5)
HP_reset()
HP_orient(LANDSCAPE)
HPscale(100)
PrInvoice(0.3,0.3,9.5,3)
HP_reset()
// now we will test downloading this invoice
// DLinvoice()
// HP_reset()
set2screen()
return
Function PrInvoice(nTop,nLeft,nWidth,nInvH)
Local nInvoice:= 18000, nTotInv := 0
Local nRscale:=HPscale()/100 // used to adjust scale where
// HPscale() has no efect
Local aCompany:={"I.L.A., Inc. ","520 W. Hwy 436 #1180",;
"Altamonte Springs, FL 32714","Tel. (407) 774-7734, Fax. (407) 774-6750"}
// Local nTop:=0.3,nLeft:=0.3
Local nLogoH:=2.2*nRscale
//Local nWidth:=7 // try changing the width and all the rest
// will be adjusted try it !
// Local nInvH:=5.5
Local nInvW:=nWidth
Local o:='',nBoxSpace:=0.2
Local nS2H:=1 // height of Sold to / ship to box
Local nS2W:=(nWidth-nBoxSpace)/2 // width of S2/S2 box
Local aSold2Box:={nTop+nLogoH,nLeft,nS2H,nS2W} //
Local aShip2Box:={nTop+nLogoH,nLeft+(nS2W*nRscale)+(nBoxSpace*nRscale),nS2H,nS2W}
Local aInvBox:={nTop+nLogoH+(aSold2Box[3]*nRscale)+(nBoxSpace*nRscale),nLeft,nInvH,nInvW}
local nWUnit:=nWidth/10*nRscale
// set array of Invoice column width
Local aColW:={nWUnit*1,nWUnit*6,nWUnit*1.2,nWUnit*1.8}
Local aInvTab:={nLeft,nLeft+nWUnit,nLeft+nWUnit*7,nLeft+nWUnit*8.2}
//Local aInvTab:={nLeft,aColW[1],aColW[1]+aColW[2],aColW[1]+aColW[2]+aColW[3]}
Local line:=0,nttop:=0,cInvoice:="",os,HPCinv:=''
Local ntdate,nQty,nUnitp,cDescr,aaddress,nLM
os:=HP_send(.f.)
HPshadow(.t.) // make shadow boxes
HPsetshadow(HPsetshadow()[1]*nRscale) // set shadow width
if HPscale() < 80
HPCinv+=HP_pitch(16,ITALIC)
HPCinv+=HP_lpi(8)
else
HPCinv+=HP_pitch(10,ITALIC)
HPCinv+=HP_lpi(5)
endif
ntTop:=nTop
// print company header
HPCinv+=HP_hline(ntTop,nLeft,nWidth,0.08,GFILLGRAY,40)
ntTop+=1.5/HP_data(D_LPI)
for line:=1 to len(aCompany)
HPCinv+=HP_atsay(ntTop,nLeft,aCompany[line])
ntTop+=1/HP_data(D_LPI)
next
HPCinv+=HP_hline(ntTop,nLeft,nWidth,0.08,GFILLGRAY,40)
ntTop+=1/HP_data(D_LPI)+0.08
nTdate:=ntTop // mark date line for later
// HPCinv+=HP_lpi(7)
// make "sold to" box
HPCinv+=HP_box(aSold2Box[1],aSold2Box[2],aSold2Box[3],aSold2Box[4])
HPCinv+=HP_atsay(aSold2Box[1]-0.5/HP_data(D_LPI),aSold2Box[2],"Sold To:")
// make "ship to" box
HPCinv+=HP_box(aShip2Box[1],aShip2Box[2],aShip2Box[3],aShip2Box[4])
HPCinv+=HP_atsay(aShip2Box[1]-0.5/HP_data(D_LPI),aShip2Box[2],"Ship To:")
// make invoice detail box
HPCinv+=HP_box(aInvBox[1],aInvBox[2],aInvBox[3],aInvBox[4])
HPCinv+=HP_hline(aInvBox[1]+1.5/HP_data(D_LPI),aInvBox[2],aInvBox[4])
HPCinv+=HP_hline(aInvBox[1],aInvBox[2],aInvBox[4],1.5/HP_data(D_LPI),GFILLGRAY,10)
HPCinv+=HP_pitch(16) // use small font for column header
// print column header at center of each col.
HPCinv+=HP_atsay(aInvBox[1]+1/HP_data(D_LPI),aInvBox[2]+;
(aColW[1]-HPstsize("QTY."))/2,"QTY.")
HPCinv+=HP_vline(aInvBox[1],aInvBox[2]+aColW[1],aInvBox[3])
HPCinv+=HP_atsay(aInvBox[1]+1/HP_data(D_LPI),aInvBox[2]+aColW[1]+;
(aColW[2]-HPstsize("Description"))/2,"Description")
HPCinv+=HP_vline(aInvBox[1],aInvBox[2]+aColW[1]+aColW[2],aInvBox[3])
HPCinv+=HP_atsay(aInvBox[1]+1/HP_data(D_LPI),aInvBox[2]+aColW[1]+aColw[2]+;
(aColW[3]-HPstsize("Unit"))/2,"Unit")
HPCinv+=HP_vline(aInvBox[1],aInvBox[2]+aColW[1]+aColW[2]+aColW[3],aInvBox[3])
HPCinv+=HP_atsay(aInvBox[1]+1/HP_data(D_LPI),aInvBox[2]+aColW[1]+aColw[2]+aColW[3]+;
(aColW[4]-HPstsize("Amount"))/2,"Amount")
// Invoice format is complete, and it's in HPCinv
HP_send(os) // restore output flag
if HPscale() < 80
HP_pitch(16)
else
HP_pitch(10,ITALIC)
endif
nInvoice:=18000 // invoice # to start
nQty:=1 // quantity
cDescr:="ProHP - Laser Printer Library" // description
nUnitp:=199.00 // unit price
nLM:=1/HP_data(D_CPI) // Relative Left margin for column
/*
You may save this invoice format to a disk file.
Save it using memowrit() and later download the invoice using memoread().
Do not forget to save the invoice coordinates, so you can
print the invoice details after downloading.
*/
memowrit("invoice.mac",HPCinv)
/* This command saves the invoice format to a file. We didn't use it here,
but this shows that you can create forms in one application, and use them
elsewhere. You probably want to create your own form library. Use this file
with applications written in other languages, just read
and send the file to the printer. */
// Open DBF file
select 1
use prohp alias pro
go top
/*
Let's store the invoice format into Macro so we do not need to send it
to the printer each time we print an invoice. That's faster because the
macro is stored in the printer memory. To activate it, send a macro call
command.
*/
HP_stmacro(1) // open macro id # 1
qqout(HPCinv) // send to printer
HP_endmacro(1,PERMMACRO) // close macro 1 and protect it from reset CMD
if HPscale() < 80 // if sizes reduced below 80%
HP_pitch(16) // change pitch
HP_lpi(8) // and LPI
else
HP_pitch(10,ITALIC) // set font to Courier 10 cpi Italic
HP_lpi(5) // 5 lines per inch
endif
while !eof()
HP_callmacro(1) // call macro # 1 (our invoice format)
// print date and invoice #
HP_atsay(nTdate,nLeft,"Date :"+dtoc(date()))
cInvoice:="Invoice # "+str(nInvoice,6)
// Right justify Invoice #
HP_atsay(nTdate,nLeft+(nWidth*nRscale)-HPstsize(cInvoice),cInvoice)
// read address into array
aAddress:={pro->name,pro->address,trim(pro->city)+', '+pro->state+' '+;
pro->zip}
// print Sold to and ship to address location using HP_aatsay()
HP_aatsay(aSold2Box[1]+1/HP_data(D_LPI),aSold2Box[2]+nLM,aAddress)
HP_aatsay(aShip2Box[1]+1/HP_data(D_LPI),aShip2Box[2]+nLM,aAddress)
// detail of invoice
HP_setpos(aInvBox[1]+2/HP_data(D_LPI),nLeft+nLM)
// If you have more than one line invoices use DO WHILE (.invoice.) here
HP_rcpos(1,,.t.) // down one line
// print quantity
HP_atsay(,aInvTab[1]+nLm,padl(str(nQty,4),HPi2col(aColW[1])-1))
// print description
HP_atsay(,aInvTab[2]+nLm,cDescr)
// print unit price
HP_atsay(,aInvTab[3]+nLm,padl(str(nUnitp,6,2),HPi2col(aColW[3])-1))
// print amount
HP_atsay(,aInvTab[4]+nLm,padl(str(nQty*nUnitp,9,2),HPi2col(aColW[4])-1))
nTotInv+=nQty*nUnitp
// ENDDO WHILE (.invoice.) here
// print totals
HP_rcpos(2,,.t.) // 2 lines down
// print Total Amounts
// first draw gray bar over the current line
HP_atsay(,aInvTab[2],HPgraytext(padl("",;
HPi2col(aColW[2]+aColW[3]+aColW[4]))))
// print 'Total '
HP_atsay(,aInvTab[3]-HPstsize("Total "),"Total ")
// Print the total amount
HP_atsay(,aInvTab[4]+nLm,padl(str(nTotInv,9,2),;
HPi2col(aColW[4])-1))
// print message at the bottom of the invoice
HP_atsay(aInvBox[1]+(aInvBox[3]*nRscale)-1/HP_data(D_LPI),aInvTab[2]+nLm,;
HPbold("DO NOT FORGET TO SEND REGISTRATION CARD."))
nInvoice++ // increment invoice number
// HP_feed(FEEDOUT) // feed the page out. (no change to the printer environment)
EXIT // for this demo we'll print only one invoice
skip // next record
enddo
HP_setpos(aInvBox[1]+(aInvBox[3]*nRscale),aInvTab[1]) // go to bottom left of invocie
// HP_rcpos(1,,.t.) // down 1 line
HP_lmiset(nLeft) // aInvTab[2]) // set tab to left of second invoice column.
qout("* ProHP creates professional forms with ease. ")
qout("* Vary Size and orientation.")
qout("* These three invoice pages were created using the same procedure.")
qout(" See 'DPRINV.PRG'.")
IF HPscale() <> 100
qout("** We specified "+ltrim(str(100-HPscale()))+"% reduction from previous form. ")
qout(space(30)+HPulstr("It doesn't get any easier than that!"))
endif
HP_feed(FEEDOUT)
return NIL
proc DLinvoice()
/*
It's simple and fast to download previously built forms of any kind.
Both methods work fine with most cases, but we recomend
the use of HPdownload() . That sends the file in binary mode to
the printer and return .F. if an error occurs during downloading.
*/
Local HPCinv:=[], cfName:="invoice.mac"
if file(cfName) // make sure we have the file
HP_pitch(10)
HP_atsay(5,2,"Using MEMOREAD()")
HPCinv := memoread(cfName) // load form into memory
qqout(HPCinv) // print it.
// if you do not need the form in memory do: QQOUT(MEMOREAD(cfName))
HP_feed(FEEDOUT)
HPdownload(cfName,"LPT1") // download invoice format
HP_atsay(5,2,"USING HPdownload()")
endif
return